package com.bsoft.gol.editor.controller;

import ctd.controller.exception.ControllerException;
import hcn.util.BaseResponse;
import com.bsoft.gol.editor.editor.EditorUser;
import com.bsoft.gol.editor.editor.qo.EditorUserQo;
import com.bsoft.gol.editor.editor.response.QueryEditorUserListResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import com.bsoft.gol.editor.service.EditorOrganizationApi;
import com.bsoft.gol.editor.service.EditorUserApi;
import com.bsoft.gol.editor.utils.CommonUtils;


@RestController
@RequestMapping(value = "/api/auth/editorUser")
public class EditorUserController {

    @Autowired
    private EditorUserApi editorUserApi;

    @Autowired
    private EditorOrganizationApi editorOrganizationApi;



    @RequestMapping("/login")
    @ResponseBody
    public BaseResponse<EditorUser> login(@RequestBody EditorUser req) throws ControllerException {

        BaseResponse<EditorUser> response = new BaseResponse<>();

            response=editorUserApi.login(req);



        return response;
    }


    @RequestMapping("/delete")
    @ResponseBody
    public BaseResponse<EditorUser> delete(@RequestBody EditorUser req) throws ControllerException {

        BaseResponse<EditorUser> response = new BaseResponse<>();

            editorUserApi.delete(req);

        return response;
    }



    @RequestMapping("/register")
    @ResponseBody
    public BaseResponse<EditorUser> register(@RequestBody EditorUser req) throws ControllerException {

        BaseResponse<EditorUser> response = new BaseResponse<>();

        if (CommonUtils.isNotEmpty(req.getUserName()) && CommonUtils.isNotEmpty(req.getLoginName())) {
            response=editorUserApi.register(req);

        } else {
            response.setCode(500);
            response.setMessage("参数缺失");
        }

        return response;
    }


    @RequestMapping("/list")
    @ResponseBody
    public  BaseResponse<QueryEditorUserListResponse> list(@RequestBody EditorUserQo req) throws ControllerException {
        BaseResponse<QueryEditorUserListResponse> response = new BaseResponse<>();
            response=editorUserApi.list(req);
        return response;
    }

    @RequestMapping("/deptList")
    @ResponseBody
    public  BaseResponse<QueryEditorUserListResponse> deptlist(@RequestBody EditorUserQo req) throws ControllerException {
        BaseResponse<QueryEditorUserListResponse> response = new BaseResponse<>();
        response=editorUserApi.deptList(req);
        return response;
    }


}
